package cn.mju.tankfighterbackend.entity.game

import cn.mju.tankfighterbackend.dto.game.GameData
import cn.mju.tankfighterbackend.entity.EntityBase
import jakarta.persistence.Entity
import lombok.ToString


@Entity
class Game : EntityBase() {

    @Volatile
    var lastFrame:Int = 0
    var maxPlayerCount:Int = 0
    val syncFrameInterval:Int = 3


    fun isSyncFrame(frameIndex:Int):Boolean{
        return frameIndex%syncFrameInterval==0;
    }

    override fun toString(): String {
        return "Game(lastFrame=$lastFrame, maxPlayerCount=$maxPlayerCount, syncFrameInterval=$syncFrameInterval)+${super.toString()}"
    }

    fun getGameData():GameData{
        return GameData(lastFrame)
    }

}
